using System;
using System.Collections.Generic;
using System.Text;

namespace BlackjackGUI
{
   #region Blackjack Enums
   public enum ValueEnum
   {
      ACE = 1,
      TWO,
      THREE,
      FOUR,
      FIVE,
      SIX,
      SEVEN,
      EIGHT,
      NINE,
      TEN,
      JACK,
      QUEEN,
      KING
   };

   public enum ColorEnum
   {
      BLACK,
      RED
   };

   public enum SuitEnum
   {
      CLUB,
      SPADE,
      HEART,
      DIAMOND
   };
   #endregion

   public class CCard
   {
      #region Contructors
      public CCard(ValueEnum value, SuitEnum suit)
      {
         m_value = value;
         m_suit = suit;
         if (suit == SuitEnum.CLUB || suit == SuitEnum.SPADE)
         {
            m_color = ColorEnum.BLACK;
         }
         else
         {
            m_color = ColorEnum.RED;
         }
      } // CCard()
      #endregion

      #region Accessors
      public ValueEnum GetValue() { return m_value; }
      public SuitEnum GetSuit() { return m_suit; }
      public ColorEnum GetColor() { return m_color; }

      public override String ToString()
      {
         string RetVal = "";

         switch (m_value)
         {
            case ValueEnum.ACE:
               RetVal += "Ace";
               break;
            case ValueEnum.TWO:
               RetVal += "Two";
               break;
            case ValueEnum.THREE:
               RetVal += "Three";
               break;
            case ValueEnum.FOUR:
               RetVal += "Four";
               break;
            case ValueEnum.FIVE:
               RetVal += "Five";
               break;
            case ValueEnum.SIX:
               RetVal += "Six";
               break;
            case ValueEnum.SEVEN:
               RetVal += "Seven";
               break;
            case ValueEnum.EIGHT:
               RetVal += "Eight";
               break;
            case ValueEnum.NINE:
               RetVal += "Nine";
               break;
            case ValueEnum.TEN:
               RetVal += "Ten";
               break;
            case ValueEnum.JACK:
               RetVal += "Jack";
               break;
            case ValueEnum.QUEEN:
               RetVal += "Queen";
               break;
            case ValueEnum.KING:
               RetVal += "King";
               break;
            default:
               RetVal += "UnknownValue";
               break;
         }

         RetVal += " of ";

         switch (m_suit)
         {
            case SuitEnum.CLUB:
               RetVal += "Clubs";
               break;
            case SuitEnum.DIAMOND:
               RetVal += "Diamonds";
               break;
            case SuitEnum.HEART:
               RetVal += "Hearts";
               break;
            case SuitEnum.SPADE:
               RetVal += "Spades";
               break;
            default:
               RetVal += "UnknownSuit";
               break;
         }
         return RetVal;
      } // ToString()

      public CardControl.CardControl GetControl()
      {
         return m_cardControl;
      }

      public string GetCardPic()
      {
         string RetVal = "";

         switch (m_suit)
         {
            case SuitEnum.CLUB:
               RetVal += "clubs";
               break;
            case SuitEnum.DIAMOND:
               RetVal += "diamonds";
               break;
            case SuitEnum.HEART:
               RetVal += "hearts";
               break;
            case SuitEnum.SPADE:
               RetVal += "spades";
               break;
            default:
               RetVal += "UnknownSuit";
               break;
         }

         RetVal += "-";

         switch (m_value)
         {
            case ValueEnum.ACE:
               RetVal += "a";
               break;
            case ValueEnum.TWO:
               RetVal += "2";
               break;
            case ValueEnum.THREE:
               RetVal += "3";
               break;
            case ValueEnum.FOUR:
               RetVal += "4";
               break;
            case ValueEnum.FIVE:
               RetVal += "5";
               break;
            case ValueEnum.SIX:
               RetVal += "6";
               break;
            case ValueEnum.SEVEN:
               RetVal += "7";
               break;
            case ValueEnum.EIGHT:
               RetVal += "8";
               break;
            case ValueEnum.NINE:
               RetVal += "9";
               break;
            case ValueEnum.TEN:
               RetVal += "10";
               break;
            case ValueEnum.JACK:
               RetVal += "j";
               break;
            case ValueEnum.QUEEN:
               RetVal += "q";
               break;
            case ValueEnum.KING:
               RetVal += "k";
               break;
            default:
               RetVal += "UnknownValue";
               break;
         }

         RetVal += "-150";

         return RetVal;
      } // GetCardPic()
      #endregion

      #region Mutators
      public void SetImage(int width, int height, int x, int y, bool faceDown)
      {
         m_cardControl = new CardControl.CardControl();
         m_cardControl.Location = new System.Drawing.Point(x, y);
         m_cardControl.Size = new System.Drawing.Size(width, height);
         if (faceDown)
         {
            m_cardControl.SetImage("back-blue-150-1");
         }
         else
         {
            m_cardControl.SetImage(GetCardPic());
         }
      }

      public void MoveCard(int x, int y)
      {
         m_cardControl.Location = new System.Drawing.Point(x, y);
      }

      public void ResizeCard(int width, int height)
      {
         m_cardControl.Size = new System.Drawing.Size(width, height);
      }

      public void FlipCard()
      {
         m_cardControl.SetImage(GetCardPic());
      }
      #endregion

      #region Members
      private ValueEnum m_value;
      private SuitEnum m_suit;
      private ColorEnum m_color;
      private CardControl.CardControl m_cardControl;
      #endregion
   }
}
